package com.xp.interview.controller;

import com.xp.interview.model.NoteModel;
import com.xp.interview.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * Created by xp on 15/10/14.
 */

@Controller
public class IndexController {

    @Autowired
    private IndexService indexService;

    @RequestMapping(value = "/index",method = RequestMethod.GET)
    public String index(Model model){

        List<NoteModel> notes = indexService.getNotes();
        model.addAttribute("notes",notes);
        return "index";
    }
}
